<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="support.*,java.util.*"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Provide Degrees - Choose Major</title>
</head>
<body>
	<h1>Provide Degrees</h1>
	
	<%
	
	student stu = (student)session.getAttribute("student");
	String firstName = (String)stu.getAttribute("firstName");
    String lastName = (String)stu.getAttribute("lastName");
	String middleName = (String)stu.getAttribute( "middleName" );
	String citizenship = (String)stu.getAttribute( "citizenship" );
	String residence = (String) stu.getAttribute( "residence" );
	String street = (String)stu.getAttribute( "street" );
	String city = (String)stu.getAttribute( "city" );
	String phone = (String)stu.getAttribute( "phone" );
	
	out.println(firstName + " " + middleName + " " + lastName +"</br>");
	out.println("Country of Citizenship: " + citizenship + "</br>");
	out.println("Country of Residence: " + residence + "</br>");
	out.println("Address </br>");
	out.println("Street: " + street + "</br>");
	out.println("City: " + city + "</br>");
	
	
	String resident = (String)stu.getAttribute( "resident" );
	if(resident != null){
		stu.setAttribute("resident",resident);
		String phoneCode = (String)stu.getAttribute( "phoneCode" );
		out.println("Resident: " + resident + "</br>");
		out.println("Phone Code: " + phoneCode + "</br>");
	}
	else if(request.getParameter( "moreDegrees" ) == null){
		String state = request.getParameter( "state" );
		String zipCode = request.getParameter( "zipCode" );
		out.println("State: " + state + "</br>");
		out.println("Zip Code: " + zipCode + "</br>");
	}
	out.println("Phone: " + phone  + "</br>");
	session.setAttribute("student", stu);

	
%>	
	
	<h2>Choose Major</h2>

	<%
		support s = new support();

		String path2 = config.getServletContext().getRealPath("majors.txt");
		Vector majors = s.getMajors(path2);

		String university = request.getParameter("university");
		
  		//if degrees is equal to null this is really bad and should almost never happen
  		DegreeContainer degrees = (DegreeContainer)session.getAttribute("DegreeContainer");

	    degree d = degrees.getLastDegree();
	    d.setAttribute("university", university);
	    
	    //add container back into session object
	    session.setAttribute("DegreeContainer", degrees);
	%>
	<h3><%=university%></h3>
	<form name="degreeForm" action="moredegrees.jsp">
		<p>Manually enter major:</p>
		<input type="text" name="majorbox" />


		<p>Or choose a major from the list.</p>

		<%
			//print all the majors
			for (int i = 0; i < majors.size(); i++){
				out.println("<input type=\"radio\" name=\"major\" value=\"" + majors.get(i) + "\">"
						+ majors.get(i) + "<br>");
			}
		%>
		<br> Month: <input type="text" name="month" />
		<br> Year: <input type="text" name="year" />
		<br> GPA: <input type="text"name="gpa" /><br>
		
		<br> Select a Title-of-Degree: 
		<select name="title">
			<option value="BS">BS</option>
			<option value="MS">MS</option>
			<option value="PhD">PhD</option>
		</select> <br>
		
		<br> Upload Transcript:
		<br><input type="file" name="transcript" /> <br>
		<br> <input type="submit" value="Submit" />
	</form>
</body>
</html>